#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int binarysearch(int start,int end,int key)
{
	int low=start,high=end;
	while(low<=high)
	{
		int mid=(low+high)/2;
		if(key==a[mid])
		{
			return mid;
		}
		else if(key>a[mid])
		{
			low=mid+1;
		}
		else if(key<a[mid])
		{
			high=mid-1;
		}
	}
}


int main()
{
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
	}
	sort(a+1,a+n+1);
	int t;
	cin >> t;
	while(t--)
	{
		int key;
		cin >> key;
		cout << binarysearch(1,n,key) << endl;
	}
	return 0;
}

